<template>
    <div class="container-content">
        <el-divider class="divider"></el-divider>
        <el-form
            ref="formRef"
            :model="formObject"
            label-width="100px"
            label-position="left"
            class="mt20"
        >
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="仓库区域名称">
                        <el-input v-model="formObject.regionName"></el-input>
                    </el-form-item>
                </el-col>
                <el-col :span="24">
                    <el-form-item label="区域编码">
                        <el-input v-model="formObject.regionCode"></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="状态">
                        <el-radio v-model="formObject.status" label="0" border
                            >正常</el-radio
                        >
                        <el-radio v-model="formObject.status" label="1" border
                            >停用</el-radio
                        >
                    </el-form-item>
                </el-col>
            </el-row>
            <el-row :gutter="20">
                <el-col :span="24">
                    <el-form-item label="备注">
                        <el-input
                            v-model="formObject.remark"
                            type="textarea"
                        ></el-input>
                    </el-form-item>
                </el-col>
            </el-row>
        </el-form>
    </div>
</template>
<script>
import {
    addAreaList,
    editAreaList,
    getDetailAreaList,
} from "@/api/system/warehouse";
export default {
    props: ["id"],
    data() {
        return {
            formObject: {
                createBy: "",
                createTime: "",
                regionCode: "",
                regionName: "",
                remark: "",
                id: "",
                searchValue: "",
                status: "",
                updateBy: "",
                updateTime: "",
                warehouseId: "",
            },
        };
    },
    methods: {
        onSubmit() {
            this.formObject.id = new Date();
            if (this.id) {
                editAreaList(this.formObject).then((res) => {
                    if (res.code === 200) {
                        this.$message({
                            message: "修改成功！",
                            type: "success",
                        });
                    }
                });
            } else {
                addAreaList(this.formObject).then((res) => {
                    if (res.code === 200) {
                        this.$message({
                            message: "新增成功！",
                            type: "success",
                        });
                    }
                });
            }
        },
        getData(id) {
            getDetailAreaList(id).then((res) => {
                this.formObject = res.data;
            });
        },
    },
    created() {
        if (this.id) {
            this.getData(this.id);
        }
    },
};
</script>
<style lang="scss" scoped>
.divider {
    margin: 0;
}
</style>
